home *** CD-ROM | disk | FTP | other *** search
- #include "ResX.h"
- #include <String.h>
-
- pascal void main ( Handle ResHandle )
- {
- GlobalsPtr Globals = (GlobalsPtr) ( (WindowPeek) FrontWindow () ) -> refCon;
- SignedByte HState;
- short fileID;
- Boolean MF;
- char *fName;
-
- /***********************************/
- /** VARIABLES FOR EXAMPLE CODE **/
- /***********************************/
- GrafPtr hostPort;
- Rect r;
- WindowPtr w;
- short fontNum, ypos = 0;
- Str255 utility_string;
-
- /********************************************/
- /* Sample of accessing the global data: */
-
- fileID = (*Globals).LfileID; /* Get the file id left file */
- fName = (char *) (*Globals).LeftFName; /* Get the file name of the left file */
- MF =(*Globals).MFActive; /* Is MultiFinder running? */
-
-
- HState = HGetState ( ResHandle ); /* This is mandatory! */
-
-
- LoadResource(ResHandle); /* This is necessary if you */
- /* plan to use it. */
- /* ResX doesn't load it. */
-
-
- /**********************
-
- your main code here...
-
- **********************/
-
- /**************************************************************/
- /***** EXAMPLE CODE - DISPLAY STUFF WE GOT FROM GLOBALPTR *****/
- /**************************************************************/
- GetPort ( & hostPort );
- r = hostPort->portRect;
- LocalToGlobal ( & topLeft ( r ) );
- LocalToGlobal ( & botRight ( r ) );
- InsetRect ( & r, 32, 32 );
-
- w = NewWindow ( (Ptr) 0L, & r, "\pShow Info", TRUE, noGrowDocProc, (WindowPtr) -1L, FALSE, 0 );
- if ( w != 0L )
- {
- SetPort ( w );
- GetFNum ( "\pGeneva", & fontNum );
- TextFont ( fontNum );
- TextSize ( 9 );
-
- /******************* FILE ID FROM GLOBALPTR ******************/
- strcpy ( (char *) utility_string, "\pFile ID from GlobalPtr: " );
- MoveTo ( 196 - StringWidth ( utility_string ), ypos += 12 );
- DrawString ( utility_string );
-
- MoveTo ( 200, ypos );
- NumToString ( (long) fileID, utility_string );
- DrawString ( utility_string );
-
- /******************* FILE ID FROM RESHANDLE ******************/
- strcpy ( (char *) utility_string, "\pFile ID from HomeResFile ( ResHandle ): " );
- MoveTo ( 196 - StringWidth ( utility_string ), ypos += 12 );
- DrawString ( utility_string );
-
- NumToString ( (long) HomeResFile ( ResHandle ), utility_string );
- MoveTo ( 200, ypos );
- DrawString ( utility_string );
-
-
- /******************* FILE NAME FROM GLOBALPTR ******************/
- strcpy ( (char *) utility_string, "\pFile Name from GlobalPtr: " );
- MoveTo ( 196 - StringWidth ( utility_string ), ypos += 12 );
- DrawString ( utility_string );
-
- MoveTo ( 200, ypos );
- DrawString ( fName );
-
- /******************* IS MULTIFINDER ACTIVE? ******************/
- strcpy ( (char *) utility_string, "\pMF from GlobalPtr: " );
- MoveTo ( 196 - StringWidth ( utility_string ), ypos += 12 );
- DrawString ( utility_string );
-
- MoveTo ( 200, ypos );
- DrawString ( (MF)?("\pTRUE"):("\pFALSE") );
-
- /******************* TELL THEM HOW TO QUIT ******************/
- strcpy ( (char *) utility_string, "\p(Click the mouse to continue.)" );
- r = w->portRect;
- MoveTo ( r.left + ( r.right - r.left - StringWidth ( utility_string ) ) / 2, r.bottom - 6 );
- DrawString ( utility_string );
-
- /******************* WAIT FOR BUTTON CLICK, THEN EXIT ******************/
- while ( Button () );
- while ( ! Button () );
- while ( Button () );
-
- HideWindow ( w );
- DisposeWindow ( w );
- }
-
- SetPort ( hostPort );
- /**************************************************************/
- /***** END OF EXAMPLE CODE ************************************/
- /**************************************************************/
-
- HSetState ( ResHandle, HState ); /* This is mandatory! */
- }
-